def prost(v):
    c = True
    for i in range(2, v):
        if v % i == 0:
            c = False
            break
    return c

def Min(n):
    c1 = 0
    Min = 0
    for i in range(n - 1, 0, -1):
        for j in range(2, i):
            if i % j == 0:
                c1 += 1
        if c1 == 0:
            Min = i
            break
        c1 = 0
    return Min

def Max(n):
    c2 = 0
    Max = 0
    while Max == 0:
        n += 1
        for i in range(2, n):
            if n % i == 0:
                c2 += 1
        if c2 == 0:
            Max = n
            break
        c2 = 0
    return Max

def chislo(n):
    v = ''
    for i in range(len(n)):
        match n[i]:
            case 'one':
                v += '1'
            case 'two':
                v += '2'
            case 'three':
                v += '3'
            case 'four':
                v += '4'
            case 'five':
                v += '5'
            case 'six':
                v += '6'
            case 'seven':
                v += '7'
            case 'eight':
                v += '8'
            case 'nine':
                v += '9'
            case 'zero': 
                v += '0'               
    return v

n = input()
n = n.split()
v = ''
v = chislo(n)
v1 = int(v)
if v1 != 0:
    c = prost(v1)
    c1 = Min(v1)
    c2 = Max(v1)
    if v1 > 99 and v1 < 1000:
        if c:
            print(v1)
        else:
            if v1 - c1 > c2 - v1:
                print(c2)
            else:
                print(c1)
    else:
        print('Wrong input')